<?php


namespace app\index\model;


use think\Model;

class News extends Model
{
    public static function getNewsList($search_group,$type)
    {
        $NewClass=new self();

        $where['n.type']=['=',$type];
        $where['n.del_flag']=['=',0];
        if($search_group) {
            $where['n.group'] = ['=', $search_group];
        }
        $data=$NewClass->alias('n')
            ->join('waybill w','n.waybill_id=w.id','left')
            ->join('logistics l','w.logistics_id=l.id','left')
            ->where($where)
            ->field('n.content,w.customer_name,w.ship_no waybill,w.logistics_waybill,if(l.type=0,l.company,w.logistics_name) logistics_company')
            ->order('n.create_time','desc')
            ->limit(0,100)->select()->toArray();
        foreach ($data as $key=>$value){
            $data[$key]['is_new']=false;
        }
        return $data;

    }

}